package org.example.controller.borrow;


import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.example.domain.Book;
import org.example.dto.Isbn;
import org.example.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author tangtl
 * @create 2021-8-9 14:14
 */
@RestController
@RequestMapping("/book")
@Slf4j
public class CommonController {


    @Autowired
    BookService bookService;

    @PostMapping("/get-token-info")
    @ApiOperation("用token获得用户信息")
    public Boolean getWxGetToken(@RequestBody Isbn req) {
        log.info("/cs/user/get-token-info 用token获得用户信息 req: {}",req);
        log.info("/cs/user/get-token-info  getWxGetToken：{}");
        return true;
    }


    @GetMapping("/all")
    @ApiOperation("所有图书列表")
    public List<Book> getBhList()  {


        return bookService.getBooks();
    }

    @GetMapping("/search")
    @ApiOperation("所有图书列表")
    public List<Book> getBhList(@RequestParam String searchStr)  {
        return bookService.searchBook(searchStr);
    }

    @GetMapping("/{isbn}")
    @ApiOperation("所有图书列表")
    public Book getBook(@PathVariable String isbn){
        return bookService.getBook(isbn);
    }

}
